/**
 * Created with JetBrains WebStorm.
 * User: peternguyen
 * Date: 21/3/13
 * Time: 3:10 PM
 * To change this template use File | Settings | File Templates.
 */

/*global App*/

describe('api_transfer', function(){
    var t_session;
    var callbackObject;
    beforeEach(function() {
        App.initSession();
        t_session = App.getSession();
        callbackObject =  function(response, e){
        };
    });

    describe('fetchToListForTransfer', function() {
        it('billpayment', function() {
            var fakeObject = {
                fetch: function(transfer, callback) {

                }
            };

            var transferObject = App.BillPayment.create();

            spyOn(App.BillPayeeListFetcher, 'create').andReturn(fakeObject);
            spyOn(fakeObject, 'fetch');

            App.api_transfer.fetchToListForTransfer(transferObject, callbackObject);

            expect(fakeObject.fetch).toHaveBeenCalledWith(transferObject, callbackObject);
        });

        it('bill payment', function() {
            var fakeObject = {
                fetch: function(transfer, callback) {

                }
            };

            var transferObject = App.BillPayment.create();

            spyOn(App.BillPayeeListFetcher, 'create').andReturn(fakeObject);
            spyOn(fakeObject, 'fetch');

            App.api_transfer.fetchToListForTransfer(transferObject, callbackObject);

            expect(fakeObject.fetch).toHaveBeenCalledWith(transferObject, callbackObject);
        });

        it('own account', function() {
            var fakeObject = {
                fetch: function(transfer, callback) {

                }
            };

            var transferObject = App.OwnAccountTransfer.create();

            spyOn(App.OwnAccountToListFetcher, 'create').andReturn(fakeObject);
            spyOn(fakeObject, 'fetch');

            App.api_transfer.fetchToListForTransfer(transferObject, callbackObject);

            expect(fakeObject.fetch).toHaveBeenCalledWith(transferObject, callbackObject);
        });

        it('3rd party', function() {
            var fakeObject = {
                fetch: function(transfer, callback) {

                }
            };

            var transferObject = App.ThirdPartyTransfer.create();

            spyOn(App.ThirdPartyPayeeListFetcher, 'create').andReturn(fakeObject);
            spyOn(fakeObject, 'fetch');

            App.api_transfer.fetchToListForTransfer(transferObject, callbackObject);

            expect(fakeObject.fetch).toHaveBeenCalledWith(transferObject, callbackObject);
        });

    });

    it('fetchFromListForTransfer', function() {
        var fakeObject = {
            fetch: function(transfer, callback) {

            }
        };

        var transferObject = App.OwnAccountTransfer.create();

        spyOn(App.FromListFetcher, 'create').andReturn(fakeObject);
        spyOn(fakeObject, 'fetch');

        App.api_transfer.fetchFromListForTransfer(transferObject, callbackObject);

        expect(fakeObject.fetch).toHaveBeenCalledWith(transferObject, callbackObject);
    });

    describe('OwnAccountToListFetcher', function() {
        var fetcher;
        var transferObject;
        beforeEach(function() {
            fetcher = App.OwnAccountToListFetcher.create();
            transferObject = App.OwnAccountTransfer.create();
        });
        it('fetch', function(){
            var responseObject = {};
            var bsoiRequestObject = {
                productFilter:{"functionCode" : 'FUNC_FT_OWN', "crDrFlag" : "CR"},
                requestHeader : t_session.getBreezeContext()
            };
            spyOn(bsoi, 'filterProductList').andCallFake(function(request, callback){
                callback(responseObject);
            });
            spyOn(fetcher, 'processList');

            fetcher.fetch(transferObject, callbackObject);

            expect(fetcher.callbackTransfer).toBe(callbackObject);
            expect(bsoi.filterProductList).toHaveBeenCalledWith(bsoiRequestObject, jasmine.any(Function));
            expect(fetcher.processList).toHaveBeenCalledWith(transferObject, responseObject);
        });
        describe('processList', function(){
            beforeEach(function() {
                fetcher = App.OwnAccountToListFetcher.create();
            });
            it('general exception handling', function(){
                spyOn(bsoi, 'isGeneralException').andReturn(true);
                spyOn(fetcher, 'callbackTransfer');

                fetcher.processList(transferObject, {});

                expect(fetcher.callbackTransfer).toHaveBeenCalledWith(null, jasmine.any(BreezeException));

            });

            it('error response handling', function(){
                spyOn(bsoi, 'isGeneralException').andReturn(false);
                spyOn(bsoi, 'isSuccessResponse').andReturn(false);
                spyOn(fetcher, 'callbackTransfer');

                fetcher.processList(transferObject, {productListResponse:{responseHeader:{errorCode:'', errorMessage:''}}});

                expect(fetcher.callbackTransfer).toHaveBeenCalledWith(null, jasmine.any(BreezeException));

            });

            it('response with data', function(){
                var account = App.HaveAccount.create();
                spyOn(bsoi, 'isGeneralException').andReturn(false);
                spyOn(bsoi, 'isSuccessResponse').andReturn(true);
                spyOn(fetcher,'generateAccountFromResponseData').andReturn(account);
                spyOn(fetcher, 'callbackTransfer');
                spyOn(App.HaveAccount,'create').andReturn({});

                fetcher.processList(transferObject, {
                    productListResponse: {
                        productList:[
                            {
                            },
                            {
                            }
                        ]
                    }
                });

                expect(fetcher.callbackTransfer).toHaveBeenCalledWith([account,account]);
                expect(fetcher.generateAccountFromResponseData).toHaveBeenCalledWith({});
            });

        });
    });

    describe('FromListFetcher', function() {
        var fetcher;
        var transferObject;
        beforeEach(function() {
            fetcher = App.FromListFetcher.create();
        });
        describe('fetch', function(){
            it('own account', function(){
                transferObject = App.OwnAccountTransfer.create();
                var responseObject = {};
                var bsoiRequestObject = {
                    productFilter:{"functionCode" : 'FUNC_FT_OWN', "crDrFlag" : "DR"},
                    requestHeader : t_session.getBreezeContext()
                };
                spyOn(bsoi, 'filterProductList').andCallFake(function(request, callback){
                    callback(responseObject);
                });
                spyOn(fetcher, 'processList');

                fetcher.fetch(transferObject, callbackObject);

                expect(fetcher.callbackTransfer).toBe(callbackObject);
                expect(bsoi.filterProductList).toHaveBeenCalledWith(bsoiRequestObject, jasmine.any(Function));
                expect(fetcher.processList).toHaveBeenCalledWith(transferObject, responseObject);
            });
            it('bill payment', function(){
                transferObject = App.BillPayment.create();
                var responseObject = {};
                var bsoiRequestObject = {
                    productFilter:{"functionCode" : 'FUNC_BP', "crDrFlag" : "DR"},
                    requestHeader : t_session.getBreezeContext()
                };
                spyOn(bsoi, 'filterProductList').andCallFake(function(request, callback){
                    callback(responseObject);
                });
                spyOn(fetcher, 'processList');

                fetcher.fetch(transferObject, callbackObject);

                expect(fetcher.callbackTransfer).toBe(callbackObject);
                expect(bsoi.filterProductList).toHaveBeenCalledWith(bsoiRequestObject, jasmine.any(Function));
                expect(fetcher.processList).toHaveBeenCalledWith(transferObject, responseObject);
            });
            it('3rd party - SCB', function(){
                transferObject = App.ThirdPartyTransfer.create();
                var responseObject = {};
                var bsoiRequestObject = {
                    productFilter:{"functionCode" : 'FUNC_FT_OTHER_SCB', "crDrFlag" : "DR"},
                    requestHeader : t_session.getBreezeContext()
                };
                spyOn(transferObject, 'isSCBTransfer').andReturn(true);
                spyOn(bsoi, 'filterProductList').andCallFake(function(request, callback){
                    callback(responseObject);
                });
                spyOn(fetcher, 'processList');

                fetcher.fetch(transferObject, callbackObject);

                expect(fetcher.callbackTransfer).toBe(callbackObject);
                expect(bsoi.filterProductList).toHaveBeenCalledWith(bsoiRequestObject, jasmine.any(Function));
                expect(fetcher.processList).toHaveBeenCalledWith(transferObject, responseObject);
            });
            it('3rd party - IBFT', function(){
                transferObject = App.ThirdPartyTransfer.create();
                spyOn(transferObject, 'isSCBTransfer').andReturn(false);
                spyOn(transferObject, 'isIBFTTransfer').andReturn(true);
                var responseObject = {};
                var bsoiRequestObject = {
                    productFilter:{"functionCode" : 'FUNC_FT_OTHER_BANK', "crDrFlag" : "DR"},
                    requestHeader : t_session.getBreezeContext()
                };
                spyOn(bsoi, 'filterProductList').andCallFake(function(request, callback){
                    callback(responseObject);
                });
                spyOn(fetcher, 'processList');

                fetcher.fetch(transferObject, callbackObject);

                expect(fetcher.callbackTransfer).toBe(callbackObject);
                expect(bsoi.filterProductList).toHaveBeenCalledWith(bsoiRequestObject, jasmine.any(Function));
                expect(fetcher.processList).toHaveBeenCalledWith(transferObject, responseObject);
            });
        });
        describe('processList', function(){
            beforeEach(function() {
                fetcher = App.FromListFetcher.create();
                transferObject = App.OwnAccountTransfer.create();
            });
            it('general exception handling', function(){
                spyOn(bsoi, 'isGeneralException').andReturn(true);
                spyOn(fetcher, 'callbackTransfer');

                fetcher.processList(transferObject, {});

                expect(fetcher.callbackTransfer).toHaveBeenCalledWith(null, jasmine.any(BreezeException));

            });

            it('error response handling', function(){
                spyOn(bsoi, 'isGeneralException').andReturn(false);
                spyOn(bsoi, 'isSuccessResponse').andReturn(false);
                spyOn(fetcher, 'callbackTransfer');

                fetcher.processList(transferObject, {productListResponse:{responseHeader:{errorCode:'', errorMessage:''}}});

                expect(fetcher.callbackTransfer).toHaveBeenCalledWith(null, jasmine.any(BreezeException));

            });

            it('response with data', function(){

                var account = App.HaveAccount.create();
                spyOn(bsoi, 'isGeneralException').andReturn(false);
                spyOn(bsoi, 'isSuccessResponse').andReturn(true);
                spyOn(fetcher,'generateAccountFromResponseData').andReturn(account);
                spyOn(account, 'isEqual').andReturn(false);
                spyOn(fetcher, 'callbackTransfer');

                fetcher.processList(transferObject, {
                    productListResponse: {
                        productList:[
                            {
                            },
                            {
                            }
                        ]
                    }
                });
                expect(fetcher.generateAccountFromResponseData).toHaveBeenCalledWith({});
                expect(fetcher.callbackTransfer).toHaveBeenCalledWith([account,account]);
            });

        });
    });

    describe('generateAccountFromResponseData', function() {
        beforeEach(function() {
            fetcher = App.FromListFetcher.create();
            transferObject = App.OwnAccountTransfer.create();
        });
        it('generateAccountFromResponseData for CASA', function() {

            var accountData = {productCategory:'CASA'};

            spyOn(App.HaveAccount, 'create').andReturn({});

            fetcher.generateAccountFromResponseData(accountData);

            expect(App.HaveAccount.create).toHaveBeenCalledWith(accountData);
        });
        it('generateAccountFromResponseData for CARD', function() {

            var accountData = {productCategory:'CARD'};

            spyOn(App.CardAccount, 'create').andReturn({});

            fetcher.generateAccountFromResponseData(accountData);

            expect(App.CardAccount.create).toHaveBeenCalledWith(accountData);
        });
    });

    describe('BillPayeeListFetcher', function() {
        var fetcher;
        var transferObject;
        beforeEach(function() {
            fetcher = App.BillPayeeListFetcher.create();
            transferObject = App.BillPayment.create();
        });
        it('fetch', function(){
            var responseObject = {};
            var bsoiRequestObject = {
                payee: {
                    payeeType : '',
                    payeeStatus : ''
                },
                requestHeader : t_session.getBreezeContext()
            };
            spyOn(bsoi, 'getBillPayeeList').andCallFake(function(request, callback){
                callback(responseObject);
            });
            spyOn(fetcher, 'processList');

            fetcher.fetch(transferObject, callbackObject);

            expect(fetcher.callbackTransfer).toBe(callbackObject);
            expect(bsoi.getBillPayeeList).toHaveBeenCalledWith(bsoiRequestObject, jasmine.any(Function));
            expect(fetcher.processList).toHaveBeenCalledWith(transferObject, responseObject);
        });
        describe('processList', function(){
            beforeEach(function() {
                fetcher = App.BillPayeeListFetcher.create();
            });
            it('general exception handling', function(){
                spyOn(bsoi, 'isGeneralException').andReturn(true);
                spyOn(fetcher, 'callbackTransfer');

                fetcher.processList(transferObject, {});

                expect(fetcher.callbackTransfer).toHaveBeenCalledWith(null, jasmine.any(BreezeException));

            });

            it('error response handling', function(){
                spyOn(bsoi, 'isGeneralException').andReturn(false);
                spyOn(bsoi, 'isSuccessResponse').andReturn(false);
                spyOn(fetcher, 'callbackTransfer');

                fetcher.processList(transferObject, {billPaymentPayeeListResponse:{responseHeader:{errorCode:'', errorMessage:''}}});

                expect(fetcher.callbackTransfer).toHaveBeenCalledWith(null, jasmine.any(BreezeException));

            });

            it('response with data', function(){
                spyOn(bsoi, 'isGeneralException').andReturn(false);
                spyOn(bsoi, 'isSuccessResponse').andReturn(true);
                spyOn(fetcher, 'callbackTransfer');
                spyOn(App.BillPaymentPayee,'create').andReturn({});

                fetcher.processList(transferObject, {
                    billPaymentPayeeListResponse: {
                        payeeList:[
                            {
                            },
                            {
                            }
                        ]
                    }
                });

                expect(fetcher.callbackTransfer).toHaveBeenCalledWith([{},{}]);
            });

        });
    });

    describe('ThirdPartyPayeeListFetcher', function() {
        var fetcher;
        var transferObject;
        beforeEach(function() {
            fetcher = App.ThirdPartyPayeeListFetcher.create();
            transferObject = App.ThirdPartyTransfer.create();
        });
        it('fetch', function() {
            var responseObject = {};
            var bsoiRequestObject = {
                payee : {
                    "payeeType" : "",
                    "payeeStatus" : ""
                },
                requestHeader : t_session.getBreezeContext()
            };
            spyOn(bsoi, 'getThirdPartyPayeeList').andCallFake(function(request, callback) {
                callback(responseObject);
            });
            spyOn(fetcher, 'processList');

            fetcher.fetch(transferObject, callbackObject);

            expect(fetcher.callbackTransfer).toBe(callbackObject);
            expect(bsoi.getThirdPartyPayeeList).toHaveBeenCalledWith(bsoiRequestObject, jasmine.any(Function));
            expect(fetcher.processList).toHaveBeenCalledWith(transferObject, responseObject);
        });
        describe('processList', function() {
            beforeEach(function() {
                fetcher = App.ThirdPartyPayeeListFetcher.create();
            });
            it('general exception handling', function(){
                spyOn(bsoi, 'isGeneralException').andReturn(true);
                spyOn(fetcher, 'callbackTransfer');

                fetcher.processList(transferObject, {});

                expect(fetcher.callbackTransfer).toHaveBeenCalledWith(null, jasmine.any(BreezeException));

            });

            it('error response handling', function(){
                var responseObject = {thirdPartyPayeeListResponse:{responseHeader:{errorCode:'', errorMessage:''}}};
                spyOn(bsoi, 'isGeneralException').andReturn(false);
                spyOn(bsoi, 'isSuccessResponse').andReturn(false);
                spyOn(fetcher, 'callbackTransfer');

                fetcher.processList(transferObject, responseObject);

                expect(fetcher.callbackTransfer).toHaveBeenCalledWith(null, jasmine.any(BreezeException));

            });

            it('response with data', function(){
                spyOn(bsoi, 'isGeneralException').andReturn(false);
                spyOn(bsoi, 'isSuccessResponse').andReturn(true);
                spyOn(fetcher, 'callbackTransfer');
                spyOn(App.ThirdPartyPayee,'create').andReturn({});

                fetcher.processList(transferObject, {
                    thirdPartyPayeeListResponse: {
                        payeeList:[
                            {
                            },
                            {
                            }
                        ]
                    }
                });

                expect(fetcher.callbackTransfer).toHaveBeenCalledWith([{},{}]);
            });
        });
    });

    describe('ConfirmOwnAccountTransfer', function() {
        var confirm;
        var transferObject;
        beforeEach(function() {
            confirm = App.ConfirmOwnAccountTransfer.create();
            transferObject = App.OwnAccountTransfer.create();

            transferObject.toAccount = App.HaveAccount.create();
            transferObject.fromAccount = App.HaveAccount.create();
        });
        it('confirm', function() {
            var responseObject = {};
            var bsoiRequestObject = {
                fundTransfer :{},
                requestHeader : t_session.getBreezeContext()
            };
            spyOn(transferObject, 'fundTransferDataVO').andReturn({});
            spyOn(App.getSession(), 'getCurrentTransfer').andReturn(transferObject);
            spyOn(bsoi, 'ownAccountTransfer').andCallFake(function(request, callback) {
                callback(responseObject);
            });
            spyOn(confirm, 'processConfirmTransferResponse');

            confirm.confirm(transferObject, callbackObject);

            expect(bsoi.ownAccountTransfer).toHaveBeenCalledWith(bsoiRequestObject, jasmine.any(Function));
            expect(confirm.processConfirmTransferResponse).toHaveBeenCalledWith(responseObject);
        });
        describe('processConfirmTransferResponse', function() {
            it('general exception handling', function(){
                spyOn(bsoi, 'isGeneralException').andReturn(true);
                spyOn(confirm, 'callbackTransfer');

                confirm.processConfirmTransferResponse({});

                expect(confirm.callbackTransfer).toHaveBeenCalledWith(null, jasmine.any(BreezeException));

            });

            it('error response handling', function(){
                var responseObject = {ownFundTransferResponse:{responseHeader:{errorCode:'', errorMessage:''}}};
                spyOn(bsoi, 'isGeneralException').andReturn(false);
                spyOn(bsoi, 'isSuccessResponse').andReturn(false);
                spyOn(confirm, 'callbackTransfer');

                confirm.processConfirmTransferResponse(responseObject);

                expect(confirm.callbackTransfer).toHaveBeenCalledWith(null, jasmine.any(BreezeException));

            });
            it('response with data with no transaction result', function(){
                var responseObject = {ownFundTransferResponse:{responseHeader:{}, transactionResult: {}}};
                var transferResult = App.TransferResult.create();
                spyOn(bsoi, 'isGeneralException').andReturn(false);
                spyOn(bsoi, 'isSuccessResponse').andReturn(true);
                spyOn(Ember,'isNone').andReturn(true);
                spyOn(confirm, 'callbackTransfer');


                confirm.processConfirmTransferResponse(responseObject);

                expect(confirm.callbackTransfer).toHaveBeenCalledWith(null);
            });
            it('response with data with transaction result', function(){
                var responseObject = {ownFundTransferResponse:{responseHeader:{}, transactionResult: {}}};
                var transferResult = App.TransferResult.create();
                spyOn(bsoi, 'isGeneralException').andReturn(false);
                spyOn(bsoi, 'isSuccessResponse').andReturn(true);
                spyOn(Ember,'isNone').andReturn(false);
                spyOn(App.TransferResult,'create').andReturn(transferResult);
                spyOn(confirm, 'callbackTransfer');


                confirm.processConfirmTransferResponse(responseObject);

                expect(confirm.callbackTransfer).toHaveBeenCalledWith(transferResult);
            });
        });
    });

    describe('ConfirmThirdPartyTransfer', function() {
        var confirm;
        var transferObject;
        beforeEach(function() {
            confirm = App.ConfirmThirdPartyTransfer.create();
            transferObject = App.ThirdPartyTransfer.create();
        });
        it('confirm', function() {
            var responseObject = {};
            var bsoiRequestObject = {
                fundTransfer :{},
                requestHeader : t_session.getBreezeContext()
            };

            spyOn(transferObject, 'fundTransferDataVO').andReturn({});
            spyOn(App.getSession(), 'getCurrentTransfer').andReturn(transferObject);
            spyOn(bsoi, 'thirdPartyTransfer').andCallFake(function(request, callback) {
                callback(responseObject);
            });

            spyOn(confirm, 'processConfirmTransferResponse');

            confirm.confirm(transferObject, callbackObject);
            expect(bsoi.thirdPartyTransfer).toHaveBeenCalledWith(bsoiRequestObject, jasmine.any(Function));
            expect(confirm.processConfirmTransferResponse).toHaveBeenCalled();
        });
        describe('processConfirmTransferResponse', function() {
            it('general exception handling', function(){
                spyOn(bsoi, 'isGeneralException').andReturn(true);
                spyOn(confirm, 'callbackTransfer');

                confirm.processConfirmTransferResponse({});

                expect(confirm.callbackTransfer).toHaveBeenCalledWith(null, jasmine.any(BreezeException));

            });

            it('error response handling', function(){
                var responseObject = {thirdPartyFundTransferResponse:{responseHeader:{errorCode:'', errorMessage:''}}};
                spyOn(bsoi, 'isGeneralException').andReturn(false);
                spyOn(bsoi, 'isSuccessResponse').andReturn(false);
                spyOn(confirm, 'callbackTransfer');

                confirm.processConfirmTransferResponse(responseObject);

                expect(confirm.callbackTransfer).toHaveBeenCalledWith(null, jasmine.any(BreezeException));

            });
            it('response with data with no transaction result', function(){
                var responseObject = {thirdPartyFundTransferResponse:{responseHeader:{}, transactionResult: {}}};
                var transferResult = App.TransferResult.create();
                spyOn(bsoi, 'isGeneralException').andReturn(false);
                spyOn(bsoi, 'isSuccessResponse').andReturn(true);
                spyOn(Ember,'isNone').andReturn(true);
                spyOn(confirm, 'callbackTransfer');


                confirm.processConfirmTransferResponse(responseObject);

                expect(confirm.callbackTransfer).toHaveBeenCalledWith(null);
            });
            it('response with data with transaction result', function(){
                var responseObject = {thirdPartyFundTransferResponse:{responseHeader:{}, transactionResult: {}}};
                var transferResult = App.TransferResult.create();
                spyOn(bsoi, 'isGeneralException').andReturn(false);
                spyOn(bsoi, 'isSuccessResponse').andReturn(true);
                spyOn(Ember,'isNone').andReturn(false);
                spyOn(App.TransferResult,'create').andReturn(transferResult);
                spyOn(confirm, 'callbackTransfer');


                confirm.processConfirmTransferResponse(responseObject);

                expect(confirm.callbackTransfer).toHaveBeenCalledWith(transferResult);
            });
        });
    });

    describe('ConfirmCreditCardPayment', function() {
        var confirm;
        var transferObject;
        beforeEach(function() {
            confirm = App.ConfirmCreditCardPayment.create();
            transferObject = App.CreditCardPayment.create();
        });
        it('confirm', function() {
            var responseObject = {};
            var bsoiRequestObject = {
                payment :{},
                requestHeader : t_session.getBreezeContext()
            };

            spyOn(transferObject, 'transferDataVO').andReturn({});
            spyOn(App.getSession(), 'getCurrentTransfer').andReturn(transferObject);
            spyOn(bsoi, 'cardTransfer').andCallFake(function(request, callback) {
                callback(responseObject);
            });

            spyOn(confirm, 'processConfirmTransferResponse');

            confirm.confirm(transferObject, callbackObject);
            expect(bsoi.cardTransfer).toHaveBeenCalledWith(bsoiRequestObject, jasmine.any(Function));
            expect(confirm.processConfirmTransferResponse).toHaveBeenCalled();
        });
        describe('processConfirmTransferResponse', function() {
            it('general exception handling', function(){
                spyOn(bsoi, 'validateResponse');
                spyOn(confirm, 'callbackTransfer');

                confirm.processConfirmTransferResponse({});

                expect(confirm.callbackTransfer).toHaveBeenCalledWith(null, jasmine.any(BreezeException));

            });

            it('error response handling', function(){
                var responseObject = {cardPaymentResponse:{responseHeader:{errorCode:'', errorMessage:''}}};
                spyOn(bsoi, 'validateResponse').andThrow(BreezeException.create());
                spyOn(confirm, 'callbackTransfer');

                confirm.processConfirmTransferResponse(responseObject);

                expect(confirm.callbackTransfer).toHaveBeenCalledWith(null, jasmine.any(BreezeException));

            });
            it('response with data with no transaction result', function(){
                var responseObject = {cardPaymentResponse:{responseHeader:{}, transactionResult: {}}};
                var transferResult = App.TransferResult.create();
                spyOn(bsoi, 'validateResponse');
                spyOn(Ember,'isNone').andReturn(true);
                spyOn(confirm, 'callbackTransfer');


                confirm.processConfirmTransferResponse(responseObject);

                expect(confirm.callbackTransfer).toHaveBeenCalledWith(null);
            });
            it('response with data with transaction result', function(){
                var responseObject = {cardPaymentResponse:{responseHeader:{}, transactionResult: {}}};
                var transferResult = App.TransferResult.create();
                spyOn(bsoi, 'validateResponse');
                spyOn(Ember,'isNone').andReturn(false);
                spyOn(App.TransferResult,'create').andReturn(transferResult);
                spyOn(confirm, 'callbackTransfer');


                confirm.processConfirmTransferResponse(responseObject);

                expect(confirm.callbackTransfer).toHaveBeenCalledWith(transferResult);
            });
        });
    });

});